package com.example.xpagedemoproject.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.xpagedemoproject1.R;
import com.xuexiang.xpage.base.XPageFragment;
import com.xuexiang.xpage.core.PageOption;
import com.xuexiang.xpage.utils.TitleBar;
import com.xuexiang.xrouter.annotation.AutoWired;
import com.xuexiang.xrouter.launcher.XRouter;

import butterknife.BindView;
import butterknife.OnClick;

public class SimpleListFragment extends XPageFragment {
    public static final String KEY_TITLE = "key_title";

    @BindView(R.id.tv_content)
    TextView tvContent;

    public static SimpleListFragment newInstance(String title){
        Bundle args = new Bundle();
        args.putString(KEY_TITLE,title);
        SimpleListFragment fragment = new SimpleListFragment();
        fragment.setArguments(args);
        return fragment;
    }
    @AutoWired(name = KEY_TITLE)
    String title;

    @Override
    protected void initArgs() {
        super.initArgs();
        XRouter.getInstance().inject(this);
    }

    @Override
    protected TitleBar initTitleBar() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_simple;
    }

    @Override
    protected void initViews() {
        tvContent.setText(String.format("这个是%s的页面",title));
    }

    @Override
    protected void initListeners() {

    }
    @OnClick(R.id.tv_test)
    protected void onViewClicked(View view){
        PageOption.to(TestFragment.class)
                .setNewActivity(true)
                .open(this);
    }
}
